public class triangle extends Shape {
private int side2;
private int side3;

class  TriangleException extends Exception{
    public TriangleException() {
        super();
    }
    public TriangleException(String message){
        super(message);
    }
}
    public triangle(int side, int side2, int side3) {
        super(side);
        this.side2 = side2;
        this.side3 = side3;
    }
    private void checkSide()throws TriangleException{
            if(side+side2<=side3){
                throw new TriangleException("三角形任意两边之和应大于第三边！");
            } else if (side3+side2<=side) {
                throw new TriangleException("三角形任意两边之和应大于第三边！");
            } else if (side+side3<=side2) {
                throw new TriangleException("三角形任意两边之和应大于第三边！");
            }else{
                return;
            }
    }
    @Override
    public double area() {
         double p = (side+side2+side3)/2.0; //海伦公式里面的P
        try {
            checkSide();
        } catch (TriangleException e) {
            throw new RuntimeException(e);
        }
         return Math.sqrt(p*(p-side)*(p-side2)*(p-side3));

    }

    @Override
    public double length() {
        return side +side2 +side3;
    }
}
